snippet sec "Section comment" !b
`!p
padding = 78 - len(t[1]) - 8
snip.rv = '#...: '
`${1:Section}`!p
snip.rv = ' :' + padding * '.'`
$0
endsnippet

snippet c++11 "Compile for the new C++ standard" !b
#...: gnu++0x
if(CMAKE_COMPILER_IS_GNUCXX)
    execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
    if(GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
        add_definitions(-std=gnu++0x)
    else(GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
        message(SEND_ERROR "You need GCC version 4.6 or greater to compile this package.")
    endif(GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
endif(CMAKE_COMPILER_IS_GNUCXX)
endsnippet

snippet werror "Warnings and errors" !b
#...: treat warnings as errors and disable centain warnings
add_definitions(-Werror)
add_definitions(-Wno-error=unused-variable)
add_definitions(-Wno-error=unknown-pragmas)
add_definitions(-Wno-unknown-pragmas)
add_definitions(-Wno-deprecated)
endsnippet

snippet wall "Warnings as errors" !b
#...: enable all but certain warnings
add_definitions(-Wall)
add_definitions(-Wno-unknown-pragmas)
add_definitions(-Wno-deprecated)
add_definitions(-fpermissive)
endsnippet

snippet exe "Add executable target" !b
add_executable(${1:test}
  ${2:src/test.cpp}
)
endsnippet

snippet lib "Add library" !b
add_library(${1:lib}
  ${2:src/lib.cpp}
)
endsnippet

snippet link "Link libraries" !b
target_link_libraries(${1:test}
  ${2:library}
)
endsnippet
